package CSDN.hzh22_7.test_2;

/**
 * @Description:
 * @Author: Hanzao
 * @Date: 2022/07/24/14:48
 */

import java.util.ArrayList;
import java.util.Scanner;

class first_hzh {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        String str_0 = scan.nextLine();
        String[] line_list_0 = str_0.trim().split(" ");
        ArrayList<Integer> arr = new ArrayList<>();
        for (int i = 0; i < line_list_0.length; i++) {
            arr.add(Integer.parseInt(line_list_0[i]));
        }


        scan.close();

        int result = solution(arr);

        System.out.println(result);

    }

    public static int solution(ArrayList<Integer> arr) {
        int result = 0;

        // TODO: 请在此编写代码
        int num = arr.get(0);
        int tmp = arr.get(1);
        for (int i = 1; i <= num; i++) {
            // 传过来的i = 123
            int res = i;
            int ttmp = 0;
            while (res != 0) {
                ttmp = res % 10;
                if(ttmp == tmp){
                    result++;
                }
                res = res / 10;
            }
        }

        // TODO: 请在此编写代码
        return result;
    }
}
